﻿using System;
using G.Runtime;

namespace Conquest
{
    public static class SelectedElement
    {
        private static GameElement _GameElement;
        
        public static GameElement GameElement
        {
            get { return _GameElement; }
            set 
            { 
                if (value == null)
                {
                    ClearSelected();
                }
                else
                {
                    _GameElement = value; 
                }
            }
        }
        
        private static void ClearSelected()
        {
            if (_GameElement != null)
            {
                GameSpace game = _GameElement.Game;
                game.Elements.Remove(_GameElement);
                _GameElement = null;
            }
        }
    }
}
